package com.pet.exchange;

import com.pet.entity.PetAdoptApplication;
import com.pet.mapper.UserInformationMapper;
import com.pet.vo.web.PetAdoptApplicationVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@Slf4j
@Component
public class PetAdoptApplicationUtil {
    @Autowired
    private UserInformationMapper userInformationMapper;

     public PetAdoptApplicationVO exchangePetAdoptApplicationUtil(PetAdoptApplication e){

        PetAdoptApplicationVO vo = new PetAdoptApplicationVO();
        BeanUtils.copyProperties(e,vo);

        //修改名字
        vo.setApplicationUser(userInformationMapper.selectName(e.getApplicationUser()));
        //修改状态
         if(e.getApplicationStatus() == 1){
             vo.setApplicationStatus("申请成功");
         }else if (e.getApplicationStatus() == 2){
             vo.setApplicationStatus("申请失败，请查看失败原因");
         }else {
             vo.setApplicationStatus("待领养");
         }
         vo.setApplicationUserImage(userInformationMapper.selectProfilePhotoById(e.getApplicationUser()));

        return vo;
    }
}
